package kr.saeildadim.androidexam_saeildamil.chapter11;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

public class Ch11_TextChangeEx extends Activity {
	EditText mEdit;
	TextView mText;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch11_textchange);
	
		mEdit = (EditText) findViewById(R.id.ch11_textedit_edit);
		mText = (TextView) findViewById(R.id.ch11_textedit_textview);
		
		
		mEdit.setFilters(new InputFilter[]{
				new InputFilter.LengthFilter(5)
		});
		mEdit.addTextChangedListener(mWatcher);
	}
	TextWatcher mWatcher = new TextWatcher() {
		
		@Override
		public void onTextChanged(CharSequence s, int start, int before, int count) {
			int etsize = mEdit.getText().toString().length();
			mText.setText("글자수"+etsize);
		}
		public void beforeTextChanged(CharSequence s, int start, int count,
				int after) {}
		public void afterTextChanged(Editable s) {}
	};
	
}
